package com.xtq;

import com.xtq.aop.Aspect;
import com.xtq.aop.proxy.AOPProxy;
import com.xtq.container.IoCContainer;
import com.xtq.service.UserService;
import com.xtq.service.UserServiceImpl;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        // 1. 创建 IOC 容器
        IoCContainer container = new IoCContainer();
        
        // 注册接口和实现类
        container.registerBean(UserService.class, UserServiceImpl.class);
        
        // 获取实际的业务实现类
        UserService userService = container.getBean(UserService.class);
        
        // 2. 创建切面列表（目前没有切面，可以传递空列表）
        List<Object> aspects = new ArrayList<>();
        Aspect aspect = new Aspect();
        aspects.add(aspect);
        // 3. 创建AOP代理对象
        UserService proxyService = AOPProxy.createProxy(UserService.class, userService, aspects);
        
        // 4. 调用代理方法，测试AOP功能
        proxyService.addUser("代理过的xtq");
        
        
        System.out.println("===============================================================");
        proxyService.deleteUser("没有代理过xtq");
    }
}
